<?
require_once('sub.inc.php');

if($_GET['m'] == "create"){
	if(isset($_GET['url'])){

		if($_GET['or'] == "ponies"){
			$GLOBALS['wloverride'] = true;
		}

		$res2 = mysqli_query($GLOBALS['con'], "SELECT `id` from `domains` WHERE `tld`='{$_SERVER['SERVER_NAME']}'");
                if( $row2 = mysqli_fetch_array($res2) ){
                        $domain = $row2['id'];
			$outdomain = strtolower($_SERVER['SERVER_NAME']);
		}else{
                        $domain = '0';
			$res3 = mysqli_query($GLOBALS['con'], "SELECT `id` from `domains` WHERE `default`='1' LIMIT 0,1");
			$row3 = mysqli_fetch_array($res3);
			$outdomain = $row3['tld'];
		}

		$result = createURL($_GET['url'], 5, $domain);

		print "http://".$outdomain."/".$result;
	}else{
		print "ERROR-NOURL";
	}
}else{
	print "ERROR-NOMODE";
}
